//
// Created by fengg on 2020/5/24.
//

#include <stdio.h>
#include <stdlib.h>


int DisplayIArray(int *lpArray,int iLower,int iUpper){
    int i;
    for (i = iLower; i <= iUpper; ++i) {
        printf("%d ",lpArray[i]);
    }
    putchar('\n');
    return 0;
}


void swap(int *lpArray, int j, int i) {
    if (j < 0 || i < 0)
        return;
    int iTemp;
    iTemp = lpArray[j];
    lpArray[j] = lpArray[i];
    lpArray[i] = iTemp;
}

int BubbleSort(int *lpArray, int iLower, int iUpper){
    int iCurrUpper = iUpper;
    int iCurrLower = iLower;
    int iTemp,iIndex;
    int j;
    for (; iCurrLower <= iCurrUpper; --iCurrUpper) {
        iIndex=-1;
        iTemp = 99999;
        for (j = iCurrLower; j <= iCurrUpper-1; ++j) {
            if(lpArray[j] > lpArray[j+1])
                swap(lpArray,j,j+1);
            if(lpArray[j] < iTemp) {
                iIndex = j;
                iTemp = lpArray[j];
            }
        }
        swap(lpArray,iCurrLower++,iIndex);
        DisplayIArray(lpArray,iLower,iUpper);
    }
}


int main(){
    int *lpArray;
    int iNumber;
    int i;
    scanf("%d",&iNumber);
    lpArray = malloc(sizeof(int)*iNumber);
    for (i = 0; i < iNumber; ++i) {
        scanf("%d",&lpArray[i]);
    }
    DisplayIArray(lpArray,0,iNumber-1);
    BubbleSort(lpArray,0,iNumber-1);
    return 0;
}
